package com.designoutput.ui.options
{
	import com.designoutput.elements.StarElement;
	import com.designoutput.event.NumberEvent;
	import com.designoutput.ui.controls.Literal;
	import com.designoutput.ui.controls.NumberInput;
	import com.designoutput.manager.ResourceManager;

	public class StarOption extends BaseRectOption
	{
		public var starPointsInput:NumberInput;
		public var groinRatioInput:NumberInput;

		public function StarOption(parent:DesignoutputCard)
		{
			super(parent);
			
			var li:Literal;

			/***************************************/
			li = new Literal(ResourceManager.getValue("rm_star_points"));
			li.x=0;
			li.y=222;
			addChild(li);

			starPointsInput=new NumberInput(40, 0, 3, 100);
			starPointsInput.addEventListener(NumberEvent.VALUE_CHANGE,starPointsChange);
			starPointsInput.x=70;
			starPointsInput.y=222;
			addChild(starPointsInput);
			
			/***************************************/
			li = new Literal(ResourceManager.getValue("rm_groin_ratio"));
			li.x=0;
			li.y=242;
			addChild(li);

			groinRatioInput=new NumberInput(40, 0, 0, 100, true);
			groinRatioInput.addEventListener(NumberEvent.VALUE_CHANGE,groinRatioChange);
			groinRatioInput.x=70;
			groinRatioInput.y=242;
			addChild(groinRatioInput);
			
			/***************************************/
			
			addChild(fillGroup);
			addChild(lineGroup);
			
			resize();
		}

		public function resize():void
		{
			depthManager.y = 267;
		}
		
		public function updateOptions(elementType:String,element:StarElement,bothShirtAndSleeves:Boolean=false,forSleeveElements:Boolean=false):void{
			super.update(element,bothShirtAndSleeves,forSleeveElements);
			this.starPointsInput.text = element.getStarPoints().toString();
			this.groinRatioInput.text = element.getStarCenterDist().toString();
		}
		
		private function starPointsChange(evt:NumberEvent):void{
			if(!isNaN(evt.value)){
				this.designOutputCard.command.changeElementStarPoints(evt.value);
			}
		}
		private function groinRatioChange(evt:NumberEvent):void{
			if(!isNaN(evt.value)){
				this.designOutputCard.command.changeElementGroinRatio(evt.value);
			}
		}
	}
}